package org.chen.spring.cloud.finchley.ch04.feign.client.service;

import org.chen.spring.cloud.finchley.ch04.feign.client.config.GithubFeignServiceConfig;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

/**
 * @author chensj
 * @date 2020-02-05 23:39
 */
@FeignClient(name = "github-feign-client",
        url = "https://api.github.com",
        configuration = GithubFeignServiceConfig.class)
public interface GithubFeignService {
    /**
     * 请求GitHub 查询仓库信息
     * {
     *   "message": "Validation Failed",
     *   "errors": [
     *     {
     *       "resource": "Search",
     *       "field": "q",
     *       "code": "missing"
     *     }
     *   ],
     *   "documentation_url": "https://developer.github.com/v3/search"
     * }
     * @param queryStr 仓库名称
     * @return
     */
    @RequestMapping(value = "/search/repositories", method = RequestMethod.GET)
    String searchRepo(@RequestParam("q") String queryStr);
}
